class Device {
  // 基本属性
  late int? deviceId;
  late String? deviceName;
  late String? deviceModel;
  late String? deviceSn;
  late int? isMqtt;
  late int? deptId;
  late int? userId;
  late String? companyId;
  late String? deviceUuid;
  late String? devicePho;
  late String? ipAddress;
  late String? macAddress;
  late int? lineStatus;
  late String? lineTime;
  late String? runTime;
  late int? deviceType;
  late int? deviceStatus;
  late int? multiple;
  late int? deviceOrder;
  late String? qrcode;
  late String? qrcodePho;
  late String? network;
  late int? networkType;
  late double? storageRemaining;
  late double? storageTotal;
  late String? storage;
  late String? zone;
  late String? version;
  late int? timeWatermark;
  late int? intercomMode;
  late int? ioAlarm;
  late int? appMessage;
  late int? zoneType;
  late int? indoorLockDelay;


  late int? createUserId;
  late String? createUserName;
  late String? brief;
  late int? del;

  // 继承BaseEntity的属性（假设BaseEntity包含createTime和updateTime）
  final String? createTime;
  final String? updateTime;

  Device({
    this.deviceId,
    this.deviceName,
    this.deviceSn,
    this.isMqtt,
    this.deviceModel,
    this.deptId,
    this.userId,
    this.companyId,
    this.deviceUuid,
    this.devicePho,
    this.ipAddress,
    this.macAddress,
    this.lineStatus,
    this.lineTime,
    this.runTime,
    this.deviceType,
    this.deviceStatus,
    this.multiple,
    this.deviceOrder,
    this.qrcode,
    this.qrcodePho,
    this.network,
    this.networkType,
    this.storageRemaining,
    this.storageTotal,
    this.storage,
    this.zone,
    this.timeWatermark,
    this.intercomMode,
    this.ioAlarm,
    this.appMessage,
    this.zoneType,
    this.indoorLockDelay,

    this.version,
    this.createUserId,
    this.createUserName,
    this.brief,
    this.del,
    this.createTime,
    this.updateTime,
  });

  // 从JSON数据创建Device实例的工厂方法
  factory Device.fromJson(Map<String, dynamic> json) {
    return Device(
      deviceId: json['deviceId'] as int?,
      deviceName: json['deviceName'] as String?,
      deviceSn: json['deviceSn'] as String?,
      isMqtt: json['isMqtt'] as int?,
      deviceModel: json['deviceModel'] as String?,
      deptId: json['deptId'] as int?,
      userId: json['userId'] as int?,
      companyId: json['companyId'] as String?,
      deviceUuid: json['deviceUuid'] as String?,
      devicePho: json['devicePho'] as String?,
      ipAddress: json['ipAddress'] as String?,
      macAddress: json['macAddress'] as String?,
      lineStatus: json['lineStatus'] as int?,
      lineTime: json['lineTime'] as String?,
      runTime: json['runTime'] as String?,
      deviceType: json['deviceType'] as int?,
      deviceStatus: json['deviceStatus'] as int?,
      multiple: json['multiple'] as int?,
      deviceOrder: json['deviceOrder'] as int?,
      qrcode: json['qrcode'] as String?,
      qrcodePho: json['qrcodePho'] as String?,
      network: json['network'] as String?,
      networkType: json['networkType'] as int?,
      storageRemaining: (json['storageRemaining'] as num?)?.toDouble(),
      storageTotal: (json['storageTotal'] as num?)?.toDouble(),
      storage: json['storage'] as String?,
      zone: json['zone'] as String?,
      version: json['version'] as String?,
      timeWatermark: json['timeWatermark'] as int?,
      intercomMode: json['intercomMode'] as int?,
      ioAlarm: json['ioAlarm'] as int?,
      appMessage: json['appMessage'] as int?,
      zoneType: json['zoneType'] as int?,
      indoorLockDelay: json['indoorLockDelay'] as int?,

      createUserId: (json['createUserId'] as num?)?.toInt(),
      createUserName: json['createUserName'] as String?,
      brief: json['brief'] as String?,
      del: json['del'] as int?,
      createTime: json['createTime'] as String?,
      updateTime: json['updateTime'] as String?,
    );
  }

  // 将Device实例转换为JSON格式
  Map<String, dynamic> toJson() {
    return {
      'deviceId': deviceId,
      'deviceName': deviceName,
      'deviceSn': deviceSn,
      'isMqtt': isMqtt,
      'deviceModel': deviceModel,
      'deptId': deptId,
      'userId': userId,
      'companyId': companyId,
      'deviceUuid': deviceUuid,
      'devicePho': devicePho,
      'ipAddress': ipAddress,
      'macAddress': macAddress,
      'lineStatus': lineStatus,
      'lineTime': lineTime,
      'runTime': runTime,
      'deviceType': deviceType,
      'deviceStatus': deviceStatus,
      'multiple': multiple,
      'deviceOrder': deviceOrder,
      'qrcode': qrcode,
      'qrcodePho': qrcodePho,
      'network': network,
      'networkType': networkType,
      'storageRemaining': storageRemaining,
      'storageTotal': storageTotal,
      'storage': storage,
      'zone': zone,
      'version': version,
      'intercomMode': intercomMode,
      'ioAlarm': ioAlarm,
      'appMessage': appMessage,
      'zoneType': zoneType,
      'indoorLockDelay': indoorLockDelay,

      'timeWatermark': timeWatermark,
      'createUserId': createUserId,
      'createUserName': createUserName,
      'brief': brief,
      'del': del,
      'createTime': createTime,
      'updateTime': updateTime,
    };
  }

  @override
  String toString() {
    return 'Device{'
        'deviceId: $deviceId, '
        'deviceName: $deviceName, '
        'deviceSn: $deviceSn, '
        'isMqtt: $isMqtt, '
        'deviceModel: $deviceModel, '
        'deptId: $deptId, '
        'userId: $userId, '
        'companyId: $companyId, '
        'deviceUuid: $deviceUuid, '
        'devicePho: $devicePho, '
        'ipAddress: $ipAddress, '
        'macAddress: $macAddress, '
        'lineStatus: $lineStatus, '
        'lineTime: $lineTime, '
        'runTime: $runTime, '
        'deviceType: $deviceType, '
        'deviceStatus: $deviceStatus, '
        'multiple: $multiple, '
        'deviceOrder: $deviceOrder, '
        'qrcode: $qrcode, '
        'qrcodePho: $qrcodePho, '
        'network: $network, '
        'networkType: $networkType, '
        'storageRemaining: $storageRemaining, '
        'storageTotal: $storageTotal, '
        'storage: $storage, '
        'zone: $zone, '
        'version: $version, '
        'timeWatermark: $timeWatermark, '
        'intercomMode: $intercomMode, '
        'ioAlarm: $ioAlarm, '
        'appMessage: $appMessage, '
        'zoneType: $zoneType, '
        'indoorLockDelay: $indoorLockDelay, '


        'createUserId: $createUserId, '
        'createUserName: $createUserName, '
        'brief: $brief, '
        'del: $del, '
        'createTime: $createTime, '
        'updateTime: $updateTime'
        '}';
  }
}